package cn.v2tila.rsosa.management.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * templates
 *
 * @author v2tila on 8:55 2019/1/9
 */
@Controller
@RequestMapping("/")
public class templatesController {
    @GetMapping("/templates")
    String test(HttpServletRequest request) {
        //逻辑处理
        request.setAttribute("key", "hello world");
        return "/index";
    }
    @GetMapping("/templates/head")
    String test2(HttpServletRequest request) {
        //逻辑处理
        return "/home";
    }

    @RequestMapping("home")
    public String toHome() {
        return "home";
    }

    @RequestMapping(value = "login")
    public String toLogin() {
        return "login";
    }

    @RequestMapping(value = "logout")
    public String logout(HttpServletRequest request){
        HttpSession session = request.getSession();
        session.setAttribute("user", null);
        return "login";
    }
}
